package frc.circuitrunners;

/** Imports */
import edu.wpi.first.wpilibj.CANJaguar;
import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.can.CANTimeoutException;

/**
 * @author James Liu
 * This package and class contain all implementation of the Shooter code
 */

public class Shooter extends RobotSubsystem{
    private CANJaguar Shooter1, Shooter2;
    public void autonomous() {
    }

    public void shoot(double speed){        
        try{
            Shooter1.setX(-speed);
            Shooter2.setX(speed);
        }catch(CANTimeoutException cante){
            //ignore, pretty normal
        }
    }
    public void init() {
        try{
            Shooter1 = new CANJaguar(5);
            Shooter2 = new CANJaguar(6);
        }catch(CANTimeoutException cante){
            cante.printStackTrace();
        }
    }

    public void teleop() {
        try{
            if(IO.getJoystickButton(IO.JOY_SHOOTER, 1)){
                double speed = (1.0 + IO.getJoystickZ(IO.JOY_SHOOTER))/2;
                Shooter1.setX(-speed);
                Shooter2.setX(speed);
            } else {
                Shooter1.setX(0.0);
                Shooter2.setX(0.0);
            }
        }catch(CANTimeoutException cante){
            //ignore, pretty normal
        }
    }
    
    public void disable() {
        try{
            Shooter1.setX(0.0);
            Shooter2.setX(0.0);
        }catch(CANTimeoutException cante){
            //ignore, pretty normal
        }
    }

    public void autoAim() {
        try{
            double speed = (1.0 + IO.getJoystickZ(IO.JOY_SHOOTER))/2;
            Shooter1.setX(-speed);
            Shooter2.setX(speed);
        }catch(CANTimeoutException cante){
            //ignore, pretty normal
        }
    }

    public void autoBalance() {
        disable();
    }
}
